import { setTheme, defaultTheme } from '@/theme'
const state = () => ({
  theme: defaultTheme, //主题  localStorage.getItem('theme') || defaultTheme,
})

const getters = {
}

const mutations = {
  updateTheme (state, theme) {
    state.theme = theme
    localStorage.setItem('theme', theme)
  },
}

const actions = {
  setTheme({ commit,  state}, theme) {
    theme = theme || state.theme
    setTheme(theme)
    commit('updateTheme', theme)
  },
}

export default {
  namespaced: true,
  getters,
  state,
  mutations,
  actions
}
